//function delete_theme_subject(id,ten){
//	   var comfirmBox;
//	 //  alert(id);
//	  // alert(ten);
//	   comfirmBox = confirm("Bạn có chác chắn muốn xóa không ?");
//	   if(comfirmBox == true)
//		  {
//		    url = '/theme/deletetheme?id='+id + '&ten=' + ten;
//			$("#formnew").load(url);
//			$("#formnew").fadeIn();
//		  }
//}

function delete_theme_subject(id,ten,stt,status){
	//alert(stt);
	 var comfirmBox;
	 comfirmBox = confirm("Bạn có chác chắn muốn xóa không ?");
	 if(comfirmBox == true)
	  {
		  if(status == 1){status = "unpublic"; }
		  else status="unpublic";
		
	   $.ajax(
	      {
	    	  type:"POST",
			  url: "/theme/deletetheme",
			  data: "id=" + id + "&ten=" + ten + "&stt=" + stt,
			  datatype: "html",
			  success: function(html)
			     {
				//  alert(html);
			
				   if(html = "remove")
					   $("#" + id).remove();
				   else if(html = "empty"){
					   $("#ma" + id).text(status);
				   }

				 }
		 });
	   
	  }
	 
}

function delete_theme_full(id){
	var comfirmBox;
	 comfirmBox = confirm("Bạn có chác chắn muốn xóa không ?");
	 if(comfirmBox == true)
	  {
		 $.ajax(
			      {
			    	  type:"POST",
					  url: "/theme/deletethemefull",
					  data: "id=" + id,
					  datatype: "html",
					  success: function(html)
					     {
						  $("#" + id).remove();
					     }
			      }
			      );
	  }
}

function showFormAddTheme(){
	url = '/theme/add-theme-subject';
	$("#formnew").load(url);
	$("#formnew").fadeIn();
}

function showFormAddThemeFull(){
	url = '/theme/add-theme-full';
	$("#form_add").load(url);
	$("#form_add").fadeIn();
}
function editTheme(id){
	//alert(id);
	url = '/theme/edit-theme-subject?id='+id;
	$("#formnew").load(url);
	
	$("#formnew").fadeIn();
}

function closeForm(){
	$("#formnew").hide();
}

function editThemeFull(id,stt){
	$("#form_add").remove();
	url = '/theme/edit-theme-full?id='+id+"&stt=" + stt;
	$("#form_edit").load(url);
	
	$("#form_edit").show();
	
}

function edit_status(id,status,stt){
	   var comfirmBox;
	   comfirmBox = confirm("Bạn có chắc chắn muốn thay đổi ?");
	  // alert(status);
	   if(comfirmBox == true)
		  {
		   $.ajax(
		      {
		    	  type:"POST",
				  url: "/theme/editstatus",
				  data: "id=" + id + "&status=" + status + "&stt=" + stt,
				  datatype: "html",
				  success: function(html)
				     {
					  
						    $("#" + id).empty();
						    $("#"+ id).prepend(html);
					    
					   // else  $("#" + id).remove();
					 }
			 });
		   
		  }
}

function sort_theme(){
	
    
		var list = $("#sortable li #ma_id");
		var temp = "";
		for(var i=0; i<list.length; i++){
	  		  if(temp != "")
		  		  temp += ",";
	  		  temp += $(list[i]).val();
		}
		
	//	alert(temp);
        $("#giatri1").val(temp);
      /*  $.ajax(
  		      {
  		    	  type:"POST",
  				  url: "/theme/sort",
  				  data: "chuoi=" + temp,
  				  datatype: "html",
  				  beforeSend: function()
			       {
				   $('#info_ajax').css("display","block");
				   $('#info_ajax').html("<img src='/images/ajaxloader.gif' alt='LOADDING...' />");
				   
				    },
  				  success: function(html)
  				     {
  					$('#info_ajax').remove();
 						   alert("Đã sort thành công !!!");
  					
  					 }
  			 });
  			 */
}

function getmodel(id,ma_id)
{
	
	url = '/theme/showtheme?model_id='+id+"&id_theme=" + ma_id;
	$("#formnew").load(url);
	
}

